<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>detail</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
    <link rel="stylesheet" href="../css/detail.css">

</head>

<body>

    <header>
        <div>
            <a href="#">小米商城</a>
            <span class="division">|</span>
            <a href="#">MIUI</a>
            <span class="division">|</span>
            <a href="#">IoT</a>
            <span class="division">|</span>
            <a href="#">云服务</a>
            <span class="division">|</span>
            <a href="#">天星数科</a>
            <span class="division">|</span>
            <a href="#">有品</a>
            <span class="division">|</span>
            <a href="#">小爱开发平台</a>
            <span class="division">|</span>
            <a href="#">企业团购</a>
            <span class="division">|</span>
            <a href="#">资质证照</a>
            <span class="division">|</span>
            <a href="#">协议规定</a>
            <span class="division">|</span>
            <a href="#" class="download-app">下载app</a>
            <span class="division">|</span>
            <a href="#">智能生活</a>
            <span class="division">|</span>
            <a href="#" class="sl">Select Location</a>
            <a href="#" class="login-status">登录</a>
            <span class="division">|</span>
            <a href="#">消息通知</a>
            <a href="#" class="shoppingCart">
            </a>
        </div>
        <div class="QRdownload-app">
            <div class="QR-img">
                <img src="../imgs/QRApp.png" alt="">
                <div>小米商城APP</div>
            </div>
            <div class="corner"></div>
        </div>
    </header>
    <nav>
        <div>
            <a href="#"></a>
            <div class="nav_drawDown">
                <div class="as">
                    <a href="#" class="add">小米手机</a>
                    <a href="#" class="add">Redmi 红米</a>
                    <a href="#" class="add">电视</a>
                    <a href="#" class="add">笔记本</a>
                    <a href="#" class="add">平板</a>
                    <a href="#" class="add">家电</a>
                    <a href="#" class="add">路由器</a>
                    <a href="#" class="add">智能硬件</a>
                    <a href="#">服务</a>
                    <a href="#">社区</a>
                    <div class="add_list">
                        <span>
                            很抱歉，目前没有推荐
                        </span>
                    </div>
                </div>
                <form class="search" action="" method="get">
                    <input type="text" placeholder="小米11">
                    <button><span class="bi bi-search"></span></button>
                </form>

            </div>
        </div>
    </nav>

    <div class="middle">
        <div class="middle-imgs">
            <div class="slideshow">
            </div>
            <div class="index-dots">
                <a class="active" number="0"></a>
                <a number="1"></a>
                <a number="2"></a>
            </div>
        </div>
        <div class="middle-caption">

        </div>
    </div>

    <footer>
        <div class="footerServer">
            <ul>
                <li>
                    <span class="bi bi-wrench"></span>
                    <span>预约维修服务</span>
                </li>
                <li>
                    <span class="bi bi-arrow-counterclockwise"></span>
                    <span>7天无理由退货</span>
                </li>
                <li>
                    <span class="bi bi-bootstrap-reboot"></span>
                    <span>15天免费换货</span>
                </li>
                <li>
                    <span class="bi bi-gift"></span>
                    <span>满69包邮</span>
                </li>
                <li>
                    <span class="bi bi-geo-alt"></span>
                    <span>520余家售后网点</span>
                </li>
            </ul>
        </div>
        <div class="sortServer">
            <div class="sortServerLeft">
                <dl>
                    <dt>帮助中心</dt>
                    <dd>账户管理</dd>
                    <dd>购物指南</dd>
                    <dd>订单操作</dd>
                </dl>
                <dl>
                    <dt>服务支持</dt>
                    <dd>售后政策</dd>
                    <dd>自助服务</dd>
                    <dd>相关下载</dd>
                </dl>
                <dl>
                    <dt>线下门店</dt>
                    <dd>小米之家</dd>
                    <dd>服务网点</dd>
                    <dd>授权体验店</dd>
                </dl>
                <dl>
                    <dt>关于小米</dt>
                    <dd>了解小米</dd>
                    <dd>加入小米</dd>
                    <dd>投资者关系</dd>
                    <dd>企业社会责任</dd>
                    <dd>廉洁举报</dd>
                </dl>
                <dl>
                    <dt>关注我们</dt>
                    <dd>新浪微博</dd>
                    <dd>官方微信</dd>
                    <dd>联系我们</dd>
                    <dd>公益基金会</dd>
                </dl>
                <dl>
                    <dt>特色服务</dt>
                    <dd>F码通道</dd>
                    <dd>礼物码</dd>
                    <dd>防伪查询</dd>
                </dl>
            </div>
            <div class="sortServerRight">
                <p>400-100-5678</p>
                <p>8:00-18:00（仅收市话费）</p>
                <div class="service"><span class="bi bi-chat-left-dots-fill"></span><span>人工客服</span></div>
                <div>关注小米：
                    <a href="https://weibo.com/xiaomishangcheng" target="_blank" class="wb"></a>
                    <a href="javascript:void(0);" id="J_followWx" class="wx"></a>
                </div>
            </div>
        </div>
    </footer>
    <div class="company-information">
        <div class="ci-container">
            <div class="ci-logo">
                <div class="bg"></div>
            </div>
            <div class="ci-information">
                <p class="sites"><a rel="nofollow" href="//www.mi.com/index.html" target="_blank">小米商城</a> <span
                        class="sep">|</span> <a rel="nofollow" href="//www.miui.com/" target="_blank">MIUI</a> <span
                        class="sep">|</span> <a rel="nofollow" href="//home.mi.com/index.html" target="_blank">米家</a>
                    <span class="sep">|</span> <a rel="nofollow" href="http://www.miliao.com/" target="_blank">米聊</a>
                    <span class="sep">|</span> <a rel="nofollow" href="//www.duokan.com/" target="_blank">多看</a> <span
                        class="sep">|</span> <a rel="nofollow" href="//game.xiaomi.com/" target="_blank">游戏</a> <span
                        class="sep">|</span> <a rel="nofollow"
                        href="//b.mi.com/?client_id=180100031058&amp;masid=17409.0358" target="_blank">政企服务</a> <span
                        class="sep">|</span> <a rel="nofollow" href="//xiaomi.tmall.com/" target="_blank">小米天猫店</a>
                    <span class="sep">|</span> <a rel="nofollow" href="//privacy.mi.com/all/zh_CN/"
                        target="_blank">小米集团隐私政策</a> <span class="sep">|</span> <a rel="nofollow"
                        href="//cdn.cnbj1.fds.api.mi-img.com/mi-mall/f516fe9e2c01.html" target="_blank">小米公司儿童信息保护规则</a>
                    <span class="sep">|</span> <a rel="nofollow"
                        href="//cdn.cnbj1.fds.api.mi-img.com/mi-mall/ded8d0e4a77d.html" target="_blank">小米商城隐私政策</a>
                    <span class="sep">|</span> <a rel="nofollow" href="//www.mi.com/about/user-agreement/"
                        target="_blank">小米商城用户协议</a> <span class="sep">|</span> <a rel="nofollow"
                        href="//static.mi.com/feedback/" target="_blank">问题反馈</a> <span class="sep">|</span> <a
                        rel="nofollow" href="javascript:void(0);" class="J_siteGlobalRegion">Select Location</a>
                </p>
                <p class="sites"><a rel="nofollow" href="http://www.mi.com/beihu" target="_blank">北京互联网法院法律服务工作站</a>
                    <span class="sep">|</span> <a rel="nofollow" href="http://www.cca.org.cn/"
                        target="_blank">中国消费者协会</a> <span class="sep">|</span> <a rel="nofollow"
                        href="http://www.bj315.org/" target="_blank">北京市消费者协会</a>
                </p>
                <p class="others-sites">
                    ©
                    <a href="javascript:;" target="_blank" title="mi.com">mi.com</a> 京ICP证110507号
                    <a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow">京ICP备10046444号</a> <a
                        rel="nofollow"
                        href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=11010802020134"
                        target="_blank">京公网安备11010802020134号</a> <a href="//www.mi.com/culture-license/"
                        target="_blank">京网文[2020]0276-042号</a> <br> <a href="//www.mi.com/medical/record/"
                        target="_blank">（京）网械平台备字（2018）第00005号</a> <a href="//www.mi.com/medical/qualification/"
                        target="_blank">互联网药品信息服务资格证 (京)-非经营性-2014-0090</a> <a href="//www.mi.com/business-license/"
                        target="_blank">营业执照</a> <a href="//www.mi.com/medical/list/" target="_blank">医疗器械质量公告</a> <br>
                    <a href="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/e0c7d4cf3b7cd88de10196e30c92e020.png"
                        target="_blank">增值电信业务许可证</a>&nbsp;网络食品经营备案 京食药网食备202010048 &nbsp;
                    <a href="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/c6859168166651511897f54fa1047fe3.png"
                        target="_blank">食品经营许可证</a> <br>
                    违法和不良信息举报电话：171-5104-4404&nbsp;<a href="https://www.mi.com/intellectual"
                        target="_blank">知识产权侵权投诉</a>&nbsp;本网站所列数据，除特殊说明，所有数据均出自我司实验室测试
                </p>
                <div class="info-links"><a rel="nofollow"
                        href="https://privacy.truste.com/privacy-seal/validation?rid=4fc28a8c-6822-4980-9c4b-9fdc69b94eb8&amp;lang=zh-cn"
                        target="_blank"><img rel="nofollow" src="https://i1.mifile.cn/f/i/17/site/truste.png"
                            alt="TRUSTe Privacy Certification"></a> <a rel="nofollow"
                        href="https://search.szfw.org/cert/l/CX20120926001783002010" target="_blank"><img rel="nofollow"
                            src="https://s01.mifile.cn/i/v-logo-2.png" alt="诚信网站"></a> <a
                        id="_xinchacharenzheng_cert_vip_kexinweb" rel="nofollow"
                        href="https://xyt.xinchacha.com/pcinfo?sn=523009637759455232&amp;certType=6"
                        target="_blank"><img rel="nofollow" src="https://xyt.xinchacha.com/img/icon/icon3.png"
                            alt="可信网站"></a> <a rel="nofollow" href="https://www.mi.com/service/buy/commitment/"
                        target="_blank"><img rel="nofollow"
                            src="https://i8.mifile.cn/b2c-mimall-media/ba10428a4f9495ac310fd0b5e0cf8370.png"
                            alt="诚信经营 放心消费"></a><a rel="nofollow"
                        href="https://webcert.cnmstl.net/cert/grade?sn=3af21034e35011eab3ea00163e068ceb"
                        class="safe-auth J_safeAuth                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              "><img
                            rel="nofollow"
                            src="https://cnbj1.fds.api.xiaomi.com/b2c-misite-activity/f1ee261b96ae71e845efba398efeca02.png"
                            class="img1"><img rel="nofollow"
                            src="https://cnbj1.fds.api.xiaomi.com/b2c-misite-activity/e0bcab4f6fe52444d56e4d05997d521a.png"
                            class="img2"></a></div>
            </div>
        </div>
    </div>
    <aside>
        <div class="tag">
            <ul>
                <li class="phone-app">
                    <div class="bi bi-phone"></div>
                    <span>手机APP</span>
                </li>
                <li>
                    <div class="bi bi-person"></div>
                    <span>个人中心</span>
                </li>
                <li>
                    <div class="bi bi-wrench"></div>
                    <span>售后服务</span>
                </li>
                <li>
                    <div class="bi bi-headset"></div>
                    <span>人工服务</span>
                </li>
                <li class="jump-spc">
                    <div class="bi bi-cart2"></div>
                    <span>购物车</span>
                </li>
                <li class="call-top">
                    <div class="bi bi-chevron-bar-up"></div>
                    <span>回顶部</span>
                </li>
            </ul>
            <div class="aside-QRdownload-app">
                <div class="QR-img">
                    <img src="../imgs/QRApp.png" alt="">
                    <div>
                        <p>扫码领取新</p>
                        <p>人百元礼包</p>
                    </div>
                </div>
                <div class="corner"></div>
            </div>
        </div>
    </aside>
</body>
<script src="../js/jquery-1.10.1.min.js"></script>
<script src="../js/general.js"></script>
<script src="../js/detail.js"></script>
<script>
    let cookieStr = document.cookie;
    let reg = /(userName)/g;
    let cookieResult = cookieStr.split("; ");
    let userName;
    for (let i = 0; i < cookieResult.length; i++) {
        let key = cookieResult[i].split("=")[0];
        let value = cookieResult[i].split("=")[1];
        console.log(key);
        if (key == "userName") {
            console.log(userName);
            userName = value;
        }
    }
    if (reg.test(cookieStr)) {
        $(".login-status").text(`欢迎你：${userName}`);
    }
    $.ajax({
        type: "GET",
        url: "../php/shopping_car.php",
        data: `userName=${userName}`,
        success: function (msg) {
            let number = JSON.parse(msg).length;
            if (number > 0) {
                let ele = `
                <span class="bi bi-cart"></span>&nbsp;&nbsp;购物车&nbsp;&nbsp;(${number})
                <div class="shoppingAnim">
                    <span>您的购物车中有${number}件商品，快去看看吧！</span>
                </div>
                `;
                $(".shoppingCart").html(ele);
            } else {
                let ele = `
                <span class="bi bi-cart"></span>&nbsp;&nbsp;购物车&nbsp;&nbsp;(0)
                <div class="shoppingAnim">
                    <span>您的购物车中没有商品，快去选购吧！</span>
                </div>
                `;
                $(".shoppingCart").html(ele);
            }
        }
    });
    fillData();
    //动态填充数据
    function fillData() {
        let search = window.location.search;
        let params = search.split("=");
        $.ajax({
            type: "GET",
            url: "../php/detail.php",
            data: `goodsId=${params[1]}`,
            success: function (data) {
                data = JSON.parse(data);
                //填充轮播图
                let imgs = data[0]["imgs"].split(";");
                for (let i = 0; i < 3; i++) {
                    let ele = `<img src="${imgs[i]}" alt="">`;
                    $(".slideshow").append(ele);
                }
                //填充商品参数
                let ele = `
                        <h2>${data[0]["title"]}</h2>
                        <p class="introduce">${data[0]["caption"]}</p>
                        <p title="企业名称：小米通讯技术有限公司
                                    企业执照注册号：91110108558521630L
                                    企业地址：北京市海淀区西二旗中路33号院6 号楼9层019号
                                    企业电话：400-100-5678
                                    营业期限：2010年08月25日 至 2040年08月24日
                                    经营范围：开发手机技术、计算机软件及信息技术；技术检测、技术咨询、技术服务、技术转让；计算机技术培训；系统集成；货物进出口、技术进出口、代理进出口；家用电器、通信设备、广播电视设备（不含卫星电视广播、地面接收装置）、机械设备、电子产品、文化用品的批发零售；维修仪器仪表；销售医疗器械I类、II、III类、针纺织品（含家纺家饰）、服装鞋帽、日用杂货、工艺品、文化用品、体育用品、照相器材、卫生用品（含个人护理用品）、钟表眼镜、箱包、家具（不从事实体店铺经营）、小饰品、日用品、乐器、自行车、智能卡；计算机、通讯设备、家用电器、电子产品、机械设备的技术开发、技术服务；销售金银饰品（不含金银质地纪念币）；家用空调的委托生产；委托生产翻译机；销售翻译机、五金交电（不含电动自行车）、厨房用品、陶瓷制品、玻璃制品、玩具、汽车零配件、食用农产品、花卉、苗木、宠物用品、建筑材料、装饰材料、化妆品、珠宝首饰、通讯设备、卫生间用品、农药；生产手机（仅限在海淀区永捷北路2号三层生产及外埠生产）；出版物批发；出版物零售；销售食品。（销售第三类医疗器械以及销售食品以及依法须经批准的项目，经相关部门批准后依批准的内容开展经营活动。）"
                            class="company-info">小米自营</p>
                        <p><span class="present-price">${data[0]["pre_price"]}元</span><del class="before-price">${data[0]["bef_price"]}元</del></p>
                        <div class="line"></div>
                        <div class="area">
                            <p><i class="bi bi-geo-alt"></i>
                                <span>北京</span>
                                <span>海淀区</span>
                                <span>清河街道</span>
                            </p>
                            <p class="tag">有现货</p>
                        </div>
                        <p class="title">选择颜色</p>
                        <div class="select-color">${data[0]["color"]}</div>
                        <div class="amount">
                            <span class="goods-infor">
                                <span>${data[0]["summarize"]}</span>
                                <span>${data[0]["pre_price"]}元&nbsp;&nbsp;<del class="before-price">${data[0]["bef_price"]}元</del></span>
                            </span>
                            <span class="price">总计：${data[0]["pre_price"]}元</span>
                        </div>
                        <div class="add-btn">
                            <button class="add-shopping-car">加入购物车</button>
                            <button class="add-like"><i class="bi bi-heart"></i>喜欢</button>
                        </div>
                        <div class="security">
                            <span><i class="bi bi-check-circle"></i>小米自营</span>
                            <span><i class="bi bi-check-circle"></i>小米发货</span>
                            <span><i class="bi bi-check-circle"></i>7天无理由退换</span>
                            <span><i class="bi bi-check-circle"></i>运费说明</span>
                            <span><i class="bi bi-check-circle"></i>企业信息</span>
                            <span><i class="bi bi-check-circle"></i>售后服务政策</span>
                            <span><i class="bi bi-check-circle"></i>七天价格保护</span>
                        </div>
                `;
                $(".middle-caption").append(ele);
            }
        });
    }
    //点击加入购物车
    addShoppingCar();
    function addShoppingCar() {
        let search = window.location.search;
        let params = search.split("=");
        $(".middle-caption").on("click", ".add-shopping-car", function () {
            console.log(params[1], userName);
            $.ajax({
                type: "GET",
                url: "../php/add_shopping_car.php",
                data: `goodsId=${params[1]}&userName=${userName}`,
                success: function (data) {
                    data = JSON.parse(data);
                    console.log(data);
                    if (data["status"]) {
                        window.location = "./shopping_car.html";
                    }
                }
            });
        });
    }
    $(".jump-spc").click(function () {
        window.location = "./shopping_car.html";
    });
</script>

</html>